// pages/mine/yaoqing/yaoqing.js
const $api = require("../../../../api/mine").API
Page({

  /**
   * 页面的初始数据
   */
  data: {
    familyList:[],
    result:[],
  },
  //跳转增加页面
  add:function(){
    wx.navigateTo({
      url: '/pages/mine/yaoqing/add/add',
      success: (result)=>{
        
      },
      fail: ()=>{},
      complete: ()=>{}
    });
  },
  onShow(e){
    var t = this,
    userinfo = wx.getStorageSync('user'),
    child_one = wx.getStorageSync('child_one'),
    data={
      'member_id':userinfo.member_id,
      'child_id':child_one.child_id
    }
    $api.getFamilyInvitation(data).then(res=>{
      console.log(res)
      t.setData({
        'familyList':res.data
      })
    })
  },
  onChange(event) {
    console.log(event)
    this.setData({
      result: event.detail,
    });
  },
  submit(){
    var t = this,
    index = t.data.result,
    lists = t.data.familyList,
    res = [],
    reslist = []
    for(var i in index){
      res.push(lists[index[i]].member_id)
      reslist.push(lists[index[i]])
    }
    var pages = getCurrentPages();
    var Page = pages[pages.length - 1];//当前页
    var prevPage = pages[pages.length - 2];  //上一个页面
    prevPage.setData({
      home:res,
      homelists:reslist
    })
    prevPage.getmoney()
    wx.navigateBack({
      delta: 1,
    })
    console.log(res)
  },
  sethome(){
    var t= this
    
  }
})